<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:c="http://java.sun.com/jsp/jstl/core"
   xmlns:p="http://primefaces.org/ui"
   xmlns:our="http://java.sun.com/jsf/composite/components/grid">

	<ui:composition template="/admin.xhtml">
   <ui:define name="page.title">
      #{msg['employee.register.title']}
   </ui:define>
   
   <f:metadata name="metadata">
      <f:viewParam name="searchType" value="#{city.searchType}" />
      <f:viewParam name="employee" value="#{employee.current}" converter="empConverter" />
   </f:metadata>
   
   <ui:define name="admin.content">
         <p:ajaxStatus onsuccess="statusDialog.hide();"/>  
           
         <p:dialog modal="true"  widgetVar="statusDialog" 
               header="Processando" draggable="false" 
               closable="false">
               
               <h:graphicImage value="/resources/images/loading.gif" />  
         </p:dialog>

      <h:form id="crud" prependId="false">
         <p:panel header="#{msg['employee.register.title']}"
            toggleable="true" toggleSpeed="100"
            toggleTitle="#{msg['employee.register.title']}">

            <p:messages />

            <h:panelGrid columns="3">
               <h:outputLabel value="#{msg['employee.register.label.code']}" />
               <p:spacer width="10" />
               <p:inputText id="code"
                     value="#{employee.current.code}"/>
               
               <h:outputLabel value="#{msg['employee.register.label.name']}"/>
               <p:spacer width="10" />
               <p:inputText id="name" value="#{employee.current.name}"/>
               
               <h:outputLabel value="#{msg['employee.register.label.user']}"/>
               <p:spacer width="10" />
               <h:panelGroup layout="block">
                  <p:inputText id="user" readonly="true" 
                     value="#{employee.current.user}"/>
                  <p:commandButton icon="ui-icon-search" 
                        title="#{msg['crud.search']}"
                        onclick="dlgSearchEmployee.show();"/>               
               </h:panelGroup>
                
                             
               <h:outputLabel value="#{msg['employee.register.label.birthday']}"/>
               <p:spacer width="10" />                 
               <p:inputMask id="birthday" value="#{employee.current.birthday}" mask="99/99/9999">
               	<f:convertDateTime dateStyle="short" pattern="dd/MM/yyyy" />
               </p:inputMask>  
              
             
                            
               
               <h:outputLabel value="#{msg['employee.register.label.email']}"/>
               <p:spacer width="10" />               
               <p:inputText id="email" value="#{employee.current.email}"/>  
               
               <p:dialog widgetVar="dlgSearchEmployee" 
            width="600" height="550"
            header="#{msg['user.list.title']}" closable="true"
            modal="true" resizable="false">
            
            <p:ajax update="user" event="close" />
            
            <our:userTable id="userList" renderSelect="true"
               renderEdit="false" renderRemove="false"
               enableSearch="true" value="#{employee.current.user}" />            
         </p:dialog>
               
                         
            </h:panelGrid>
            
            <p:spacer height="15" />
            <br/>
            
            <p:commandButton id="save" 
               value="#{msg['crud.save']}" 
               update="@form" process="@form" action="#{employee.save}" />
               
            <p:commandButton id="cancel"
               value="#{msg['crud.cancel']}" 
               async="true" update="crud" immediate="true" />
         </p:panel>
         
         <p:spacer height="15" />
            
         <p:panel id="list" toggleable="true" toggleSpeed="100" 
            toggleTitle="#{msg['employee.list.title']}"
            header="#{msg['employee.list.title']}">
            <ui:include src="/employee-list.xhtml" />
         </p:panel>
         
         
         
      </h:form>
      
   </ui:define>
</ui:composition>
</html>
